import cityJson from './city.json'
const jsonObj = JSON.stringify(cityJson)
const data = JSON.parse(jsonObj)

export default [
  // 获取城市列表
  {
    url: '/city_list',
    type: 'get',
    response: () => {
      return {
        data
      }
    }
  },

  // 获取具体城市信息
  {
    url: '/city',
    type: 'get',
    response: config => {
      const {cityName} = config.query
      const city = data.cities.reduce((accu, city) => {
        city.list.find(item => {
          if (cityName.indexOf(item.name) > -1) {
            accu = item
          }
        })
        return accu
      })
      return {
        city
      }
    }
  },

  {
    url: '/hot_city',
    type: 'get',
    response: () => {
      return {
        hot_city: {
          code: "0839",
          name: "广元",
          pinyin: "Guangyuan",
          label: "Guangyuan0839"
        }
      }
    }
  }
]
